// Copyright 2017 Baidu Inc. All Rights Reserved.
// Author: Su Hao (suhao@baidu.com)
//
// Description: Adapter for mbed-trace.

#include "baidu_ca_mbedtrace.h"
#include "baidu_ca_internal.h"
#include "mbed-trace/mbed_trace.h"
#include "duer_log.h"

// Suppress Compiler warning Function declared never referenced
#define SUPPRESS_WARNING(func) (void)(func)

BCA_LOC_IMPL void bca_coap_mbed_trace(const char* msg) {
    //BCA_LOGI_EXT(NULL, 0, "### %s", msg);
    DUER_LOGI("### %s", msg);
}

BCA_INT_IMPL void bca_mbed_trace_enable(void) {
    SUPPRESS_WARNING(bca_coap_mbed_trace);
    mbed_trace_init();
    mbed_trace_config_set(TRACE_MODE_PLAIN | TRACE_ACTIVE_LEVEL_ALL);
    mbed_trace_print_function_set(bca_coap_mbed_trace);
}

BCA_INT_IMPL void bca_mbed_trace_disable(void) {
    mbed_trace_free();
}
